*--------------------------------------------------------------; * Estimates the population mean or total for a probability ; * proportional to size sample, in which the sizes of the ; * elements, relative to the population are stored in SAS ; * variable PI. ; *--------------------------------------------------------------; %macro est_pps(sample=,setup=,npop=,n=,response=,param=,pi=, mi=,m=); %if %length(&sample) = 0 %then %let sample = %str(sample); %if %length(&npop) = 0 %then %let npop = %str(npop); %if %length(&setup) > 0 %then %let tem = %str(merge est_ &setup); %else %let tem = %str(set est_); data temp_(keep=ypi_); set &sample; %if %length(&pi) > 0 %then %do; ypi_ = &response/π %end; %else %do; %if %length(&setup) > 0 %then %do; if _n_ = 1 then set &setup; %end; ypi_ = &response/(&mi/&m); %end; proc means data = temp_ noprint; var ypi_; output out = est_ mean = ypbar_ var = s2_ n=n_; data est_; &tem; tau_hat_ = ypbar_; var_ = s2_/n_; tau_std_ = sqrt(var_); bnd_tau_ = 2*tau_std_; mu_hat_ = tau_hat_/&npop; var_ = var_/&npop**2; mu_std_ = sqrt(var_); bnd_mu_ = 2*mu_std_; keep mu_hat_ tau_hat_ tau_std_ mu_std_ bnd_mu_ bnd_tau_ n_; %if %index(%upcase(¶m),MEAN) > 0 %then %do; proc print data = est_ noobs split='*'; label mu_hat_ = 'Estimate'; label mu_std_ = 'Standard*Error'; label bnd_mu_ = 'Bound'; label n_ = 'Sample*Size'; title1 "Estimate of the Population Mean"; title2 "Probability Proportional to Size Design"; title3 "Response Variable = &response"; var mu_hat_ mu_std_ bnd_mu_ n_; %end; %if %index(%upcase(¶m),TOTAL) > 0 %then %do; proc print data = est_ noobs split = '*'; label tau_hat_ = 'Estimate'; label tau_std_ = 'Standard*Error'; label bnd_tau_ = 'Bound'; label n_ = 'Sample*Size'; title1 "Estimate of the Population Total"; title2 "Probability Proportional to Size Design"; title3 "Response Variable = &response"; var tau_hat_ tau_std_ bnd_tau_ n_; %end; run; title; %mend est_pps;